<?php
/**
 * Created by PhpStorm.
 * User: tingyugetc
 * Date: 16/12/24
 * Time: 下午3:37
 */

namespace App\Repositories;


use App\Models\Setting;

class SettingRepository
{
    use BaseRepository;

    public static function getAgentSetting() {
        $agentSetting = Setting::whereIn('id', [1, 2])->get();

        $config = [];
        foreach ($agentSetting as $item) {
            $config[$item->name] = $item->value;
        }
        return $config;
    }

    public static function setAgentSetting($service_year, $share_expire) {
        $setting = Setting::find(1);
        $setting->value = $service_year;
        $setting->save();

        $setting = Setting::find(2);
        $setting->value = $share_expire;
        $setting->save();
    }

}